#{extends 'CRUD/layout.html' /}
#{set title:messages.get('surveys') /}

<script>
$(document).ready(function() {
	$("tbody tr").each(function() {
		$(this).removeClass("odd").removeClass("even");
		$(this).find("td").each(function() {
			var link = $(this).find('.hiddenLinks').text();
			$(this).click(function() {
				$(location).attr("href", link);
			});
			$(this).hover(
			  function () {
			    $(this).addClass("hover");
			  },
			  function () {
			    $(this).removeClass("hover");
			  });
		});	
	});
});
</script>

<div id="crudList" class="${type.name}">

    <h2 id="crudListTitle">&{'surveys'}</h2>

    <div id="crudListSearch">
        #{crud.search /}
    </div>

    <div id="crudListTable">
        #{crud.table fields:['surveyDate', 'alergeticDifficultyDegree', 'alergeticInsufficiencyDegree', 'user', 'medicineCard']}
           #{crud.custom 'surveyDate'}
           		<span class="hiddenLinks">@{Surveys.show(object.surveyId)}</span>
               	${object.surveyDate.format()}
		   #{/crud.custom}
		   #{crud.custom 'user'}
		   		<span class="hiddenLinks">@{Users.show(object.user.userId)}</span>
               	${object.user}
		   #{/crud.custom}
		   #{crud.custom 'medicineCard'}
		   		<span class="hiddenLinks">@{MedicineCards.show(object.medicineCard.medicineCardId)}</span>
           	    &{'title.edit'}
		   #{/crud.custom}		   
	    #{/ crud.table}
    </div>

    <div id="crudListPagination">
        &{'total', models.Survey.count()}
        #{pagination /}
    </div>

    <p id="crudListAdd">
        <a href="@{blank()}">&{'survey.add'}</a>
    </p>

</div>
